Birmingham | 26-SDC-Mar | Chioma Okeke | Sprint 2 | jq#403
Birmingham | 26-SDC-Mar | Chioma Okeke | Sprint 2 | jq#403JanefrancessC wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Your solution works. I just have a few questions.
| # The input for this script is the person.json file. | ||
| # TODO: Write a command to output the name of the person. | ||
| # Your output should be exactly the string "Selma", but should not contain any quote characters. | ||
| jq -r '.name' < person.json No newline at end of file |
There was a problem hiding this comment.
Why not specify the file input directly as
jq -r '.name' person.json
That is, without using input redirection?
There was a problem hiding this comment.
I used redirection as a reminder of different approaches I can use to solve the problem.
There was a problem hiding this comment.
You could leave a note in the script and even include in the note all possible alternatives and their pros and cons.
| # The input for this script is the person.json file. | ||
| # TODO: Write a command to output the address of the person, all on one line, with a comma between each line. | ||
| # Your output should be exactly the string "35 Fashion Street, London, E1 6PX", but should not contain any quote characters. | ||
| jq -jr '.address | join(", "), "\n"' < ./person.json No newline at end of file |
There was a problem hiding this comment.
Why use -j option and then manually output the newline character? (Your commands in other script don't follow this approach)
There was a problem hiding this comment.
Read about the -j flag as well, just a reminder that it takes out `\n' characters.
Learners, PR Template
Self checklist
Changelist
Completed exercises in
/jq.